<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>用户管理</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/treeview.jsp" %>
	<style type="text/css">
		.ztree {overflow:auto;margin:0;_margin-top:10px;padding:10px 0 0 10px;}
	</style>
</head>
<body>
	<sys:message content="${message}"/>
	<div id="content" class="row-fluid">
		<div id="left" class="accordion-group">
			<div class="accordion-heading">
		    	<a class="accordion-toggle">字典项<i class="icon-refresh pull-right" onclick="refreshTree();"></i></a>
		    </div>
		    <div style="position:absolute;right:8px;top:5px;cursor:pointer;" onclick="search();">
				<i class="icon-search"></i><label style="display: none;" id="txt">搜索</label>
			</div>
		    <div id="search" class="form-search hide" style="padding: 10px 0px 0px 13px; display: block;">
				<!-- <label for="key" class="control-label" style="padding:5px 5px 3px 0;">关键字：</label> -->
				<input class="empty" id="key" name="key" maxlength="50" style="width:80px;" type="text">
				<button class="btn" id="btn" onclick="searchNode()">搜索</button>
			</div>
			<div id="ztree" class="ztree"></div>
		</div>
		<div id="openClose" class="close">&nbsp;</div>
		<div id="right">
			<iframe id="officeContent" src="${ctx}/sys/dict/list" width="100%" height="91%" frameborder="0"></iframe>
		</div>
	</div>
	<script type="text/javascript">
	
		var treeId = 'ztree';
		var setting = {data:{simpleData:{enable:true,idKey:"id",pIdKey:"pId",rootPId:'100'}},
			callback:{onClick:function(event, treeId, treeNode){
					var id = treeNode.id == '0' ? '' :treeNode.id;
					$('#officeContent').attr("src","${ctx}/sys/dict/list?dict.type="+id+"&dict.name="+treeNode.name);
				}
			}
		};
		
		function refreshTree(){
			$.getJSON("${ctx}/sys/dictitem/treeData",function(data){
				
				$.fn.zTree.init($("#"+treeId), setting, data).expandAll(true);
				var treeObj = $.fn.zTree.getZTreeObj(treeId);
				var nodes = treeObj.getNodes();
				if (nodes.length>0) {
					//nodes[0].checked = true;
					treeObj.selectNode(nodes[0],true);
				}
			});
		}
		refreshTree();
		 
		var leftWidth = 180; // 左侧窗口大小
		var htmlObj = $("html"), mainObj = $("#main");
		var frameObj = $("#left, #openClose, #right, #right iframe");
		function wSize(){
			var strs = getWindowSize().toString().split(",");
			htmlObj.css({"overflow-x":"hidden", "overflow-y":"hidden"});
			mainObj.css("width","auto");
			frameObj.height(strs[0] - 5);
			var leftWidth = ($("#left").width() < 0 ? 0 : $("#left").width());
			$("#right").width($("#content").width()- leftWidth - $("#openClose").width() -5);
			$(".ztree").width(leftWidth - 10).height(frameObj.height() - 46);
		}
		
		function getSelectNode(){
			var treeObj = $.fn.zTree.getZTreeObj(treeId);
			return treeObj.getSelectedNodes();
		}
	</script>
	<script src="${ctxStatic}/common/wsize.min.js" type="text/javascript"></script>
</body>
</html>